pp108 : Creating an XPath Expression

Creating an XPath Expression

This topic describes the procedure to create an XPath expression using the XPath Editor.

XPath 1.0 is a language that you can use to select one or more nodes from XML. It is also used for creating static expressions and evaluating conditions based on data from XML. You can use the XPath Editor to create or modify XPath expressions. Refer to http://www.w3.org/TR/xpath for the XPath 1.0 specifications. For information on the custom functions supported by XPath, refer to Rule Engine Function Library.

  1. Click Expression Editor link in the assignment row of the Message Map. The XPath Editor dialog box appears.
  2. Use the following features to create an XPath expression:
    • Drag & Drop: You can drag a node from the Tree tab to the XPath text area. The XPath of the node will appear in the XPath text area. Drag a function and/or operator from the Functions and Operators menu to insert it in the XPath.
    • Intellisense: This feature prompts you with options to complete the XPath expression. Using the Intellisense feature, you can insert the appropriate property in the XPath. Press CTRL key + space bar on the keyboard to access the context menu displaying the available options to insert at the position in the XPath.
    • Context Menu: Right-click a node in the Tree tab to access the context menu. The following options are available in the context menu:

      Option

      Use

      Expand All

      Expands all connected sub-nodes of the selected node.

      Use =>

      Inserts the selected node in the XPath. In the Functions and Operators menu, this option will insert the function or operation in the XPath. By default. the selected node will be inserted at the place where the XPath was last edited. This option works the same way as the Use => button under the respective menus.

    • Auto Validate: Click the Auto Validate option to switch on the auto validation feature. The place under the Test Result area will have text appearing in red if the current XPath is not valid.
    • Color Code: The text of the expression is color coded. This helps in checking if strings are closed correctly, function names are recognized, and presents an overview of elements, attributes, functions, strings, numbers, etc., that are used in the expression.
  3. Click Validate. A message notifies the validity of the expression.
  4. Click Test.

The expression is validated and evaluated. If the expression and XML is valid the result is displayed in the Test Result area of the XPath Editor.

Note:

  1. All XPath expressions are supported in Message Map 'Expression'. You can also use static Java in rules.
  2. Complex expressions that can be dynamically added through the XPath editor, such as if-then-else conditions, substring(string, startindex, length) and so on, are not supported in the Case Modeling Message Map. However, you can directly assign values in the message map.


Related tasks

Creating a Message Map
Creating a Process Specific Message
Creating Assignments

Related reference

XPath Editor
Keyboard Shortcuts
Using Intellisense
Rule Engine Function Library